<?php
/**
 *
 * @author MF
 * @version 
 */
require_once 'Zend/Loader/PluginLoader.php';
require_once 'Zend/Controller/Action/Helper/Abstract.php';

/**
 * JsonEncoding Action Helper 
 * 
 * @uses actionHelper Zend_Controller_Action_Helper
 */
class Zend_Controller_Action_Helper_JsonEncoding extends Zend_Controller_Action_Helper_Abstract {
	/**
	 * @var Zend_Loader_PluginLoader
	 */
	public $pluginLoader;
	
	/**
	 * Constructor: initialize plugin loader
	 * 
	 * @return void
	 */
	public function __construct() {
		// TODO Auto-generated Constructor
		$this->pluginLoader = new Zend_Loader_PluginLoader ( );
	}
	
	/**
	 * Converts all objects into array from utf-8 into windows-1251
	 * @param array|string $post_data
	 */
	public function direct($post_data) {
		if (gettype($post_data)=='array') {
			$keys  = array_keys($post_data);
			foreach ($keys as $key) {
				$post_data[$key] = iconv('utf-8','windows-1251',$post_data[$key]);
			}
		} else {
			$post_data = iconv('utf-8','windows-1251',$post_data);
		}
		
		return $post_data;
	}
}

